import { ref, watch, reactive } from 'vue'
import RequestTodo from '@/uses/requestTodo'

export default () => {
    //添加
    const form = reactive({ title: '' })
    const showForm = ref(false)
    const loading = ref(false)
    const RequestList = RequestTodo()
    const store = async () => {
        loading.value = true
        return await fetch(`http://localhost:3002/todos`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(form) }).then(
            _ => {
                loading.value = false
                RequestList.load()
            }
        )
    }
    return { form, showForm, store, loading }
}
